
@extends('layout.default')

@section('layout.breadcrumb')
  <div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs">      
    <div class="dataTables_paginate paging_bootstrap">      
      {{$shops->links()}}
    </div>
    <div class="form-group">
      <div class="input-group" style="width:350px;">
          <input type="text" class="form-control" id="acco" name="acco" maxlength="13" placeholder="门店名/核销员/对接人" autocomplete="off" value="">
          <span class="input-group-btn">
            <button class="btn btn-primary" id="btn-sign" type="submit" style="height:34px;">
            <i class="ace-icon fa fa-search"></i> 查询
            </button>
            <a class="btn btn-inverse create-shop" style="height:34px;">
              <i class="ace-icon fa fa-leaf"></i> 新增
            </a>
          </span>
      </div>
    </div>
  </div>
@stop

@section('layout.content') 


<div class="row">
  <div class="col-xs-12">
    <input type="hidden" name="_method" value="put" />
    <table class="table table-hover table-bordered table-striped">
      <thead>
        <tr>
          <th style="min-width:85px;">编号</th>
          <th style="min-width:225px;">门店名</th>
          <th class="center" style="min-width:50px;">类型</th>
          <th style="min-width:140px;">经营类目</th>
          <th class="center" style="min-width:50px;">商品</th>
          <th class="center" style="min-width:80px;">订单</th>
          <th class="center align-right" style="min-width:70px;">已提现</th>
          <th class="center align-right" style="min-width:70px;">余额</th>
          <th style="min-width:90px;">核销员</th>
          <th style="min-width:50px;">地区</th>
          <th style="min-width:70px;">对接</th>
          <th class="center" style="min-width:50px;">流程</th>
          <th class="center" style="min-width:50px;">状态</th>
        </tr>
      </thead>

      <tbody>
      @foreach ($shops as $shop)
        <tr>
          <td class="align-left td-shop">
            {{ $shop->id }}
            <div class="pull-right operate">
              <a href="javascript:;" class="red edit-shop" data-id="{{$shop->id}}"><i class="fa iconfont">&#xe760;</i></a>
            </div>
          </td>
          <td class="align-middle wrap">{{ $shop->name }}</td>
          <td class="align-center">{!! $shop->present()->shopTrade !!}</td>
          <td class="align-middle">{{ $shop->category->parent->name }} \ {{ $shop->category->name }}</td>
          <td class="align-center">{{ $shop->products->count() }}</td>
          <td class="align-center">119 / 180</td>
          <td class="align-center align-right">11099.00</td>
          <td class="align-center align-right">{{ $shop->account->available }}</td>
          <td class="align-middle">{{ $shop->member->mobile }}</td>
          <td class="align-middle">{{ $shop->branch->name }}</td>
          <td class="align-middle">{{ $shop->staff->name }}</td>
          <td class="align-center">
            <div class="btn-group">
              <a href="javascript:;" data-toggle="dropdown" class="btn-link btn-dropdown dropdown-toggle" style="text-decoration: none;">
                {!! $shop->present()->shopProgress !!}
              </a>
              <ul class="dropdown-menu dropdown-light dropdown-menu-right dropdown-caret dropdown-close">
                <li>
                  <a href="javascript:;">
                    <span class="grey"><i class="iconfont bigger-120" data-id="{{ $shop->id }}">&#xe995;</i>
                    合作洽谈</span>
                  </a>
                </li>
                <li>
                  <a href="javascript:;">
                    <span class="blue"><i class="iconfont bigger-120" data-id="{{ $shop->id }}">&#xe984;</i>
                    合同已签</span>
                  </a>
                </li>
                <li>
                  <a href="javascript:;">
                    <span class="red"><i class="iconfont bigger-120" data-id="{{ $shop->id }}">&#xe99b;</i>
                    文案完成</span>
                  </a>
                </li>
                <li>
                  <a href="javascript:;">
                    <span class="brown"><i class="iconfont bigger-120" data-id="{{ $shop->id }}">&#xe99e;</i>
                    产品制作</span>
                  </a>
                </li>
                <li class="divider"></li>
                <li>
                  <a href="javascript:;">
                    <span class="green"><i class="ace-icon fa fa-check" data-id="{{ $shop->id }}"></i>
                    门店上线</span>
                  </a>
                </li>

              </ul>
            </div>
          </td>
          <td class="align-center">
            <div class="btn-group">
              <a href="javascript:;" data-toggle="dropdown" class="btn-link btn-dropdown dropdown-toggle">
                {!! $shop->present()->shopStatus !!}
              </a>
              <ul class="dropdown-menu dropdown-light dropdown-menu-right dropdown-caret dropdown-close">                
                <li>
                  <a href="javascript:;">
                    <span class="blue"><i class="ace-icon fa fa-edit" data-id="{{ $shop->id }}"></i></span>
                    编辑
                  </a>
                </li>
                <li class="divider"></li>
                <li>
                  <a href="javascript:;">
                    <span class="green"><i class="ace-icon fa fa-circle status" data-id="{{ $shop->id }}"></i>
                    正常</span>
                  </a>
                </li>
                <li>
                  <a href="javascript:;">
                    <span class="blue"><i class="ace-icon fa fa-play status" data-id="{{ $shop->id }}"></i>
                    审核中</span>
                  </a>
                </li>
                <li>
                  <a href="javascript:;">
                    <span class="red"><i class="ace-icon fa fa-close status" data-id="{{ $shop->id }}"></i>
                    审核失败</span>
                  </a>
                </li>
                <li class="divider"></li>
                <li>
                  <a href="javascript:;">
                    <span class="grey"><i class="ace-icon fa fa-circle status" data-id="{{ $shop->id }}"></i>
                    关闭</span>
                  </a>
                </li>

              </ul>
            </div>
          </td>
          
        </tr>
        @endforeach
      </tbody>
    </table>
    
  </div><!-- /.col -->
</div><!-- /.row -->

<div class="row">
  <div class="col-xs-12">
    <div class="dataTables_paginate paging_bootstrap">      
      {{$shops->links()}}
    </div>
  </div>
</div>
@stop

@section('javascript')
<script type="text/javascript">

  $(function() {


    $('.create-shop').on('click', function() {
      var uri = '{{route("merchant.shop.create")}}';
      layer.open({
          type: 2,
          title: '新增门店',
          area: ['960px', '580px'],
          shade: 0.8,
          content: uri,
        });      
    });

    $('.edit-shop').on('click', function() {
      var id = $(this).data('id');
      var uri = '/system/permission/'+id+'/edit';      
      layer.open({
          type: 2,
          title: '权限设置',
          area: ['360px', '560px'],
          shade: 0.8,
          content: uri,
        });      
    });


    $('.status').on('click', function() {
      var that = $(this);
      var id = that.data('id');
      //var uri = '/system/permission/change/'+id;
      $.post(uri, {
        '_token':$("input[name='_token']").attr('value'),
        '_method': $("input[name='_method']").attr('value'),
        'is_submit': true
      }, function(data) {
          if (data.status === true) {
            if(data.data.status == 1)
              that.parent().attr('class','red');
            else
              that.parent().attr('class','green');
          }
      },'json').error(function(data){
        layer.msg(data.responseJSON.message);
      }); 
    });
    
    
    $('.td-shop').on('mouseenter', function () {
        $(this).find('.operate').show();
    }).on('mouseleave', function () {
        $(this).find('.operate').hide();
    });
    
  });



</script>
@stop